<?php

namespace Dcat\Admin\ApiTester\Actions\Form;

use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
use Validator;
use Illuminate\Support\Carbon;

class SetCommonForm extends Form implements LazyRenderable {
    use LazyWidget; // 使用异步加载功能

    protected $payload = [];

    public function payload(array $payload) {
        $this->payload = array_merge($this->payload, $payload);

        return $this;
    }

    // 处理请求
    public function handle(array $input) {

        // 发送通知
        return $this->response()->success('操作成功')->refresh();
    }

    public function form() {
        // 获取外部传递参数
        //$id = $this->payload['id'] ?? null;

        $this->select('status', '审核状态')
            ->options(['0'=>'123'])->required();
        // 密码确认表单
        $this->textarea('verify_msg', '审核说明');

        $this->hidden('id')->attribute('id', 'reset-password-id');
    }

    // 返回表单数据，如不需要可以删除此方法
    /*public function default()
    {
        return [
            'password'         => '',
            'password_confirm' => '',
        ];
    }*/
}
